/*-----------------------------------------
file name  : rdy_defines.sv
created    : 2025/10/04 10:41:03
modified   : 2025-10-08 21:36:32
description: 
notes      : 
author     : yyrwkk
-----------------------------------------*/
`ifndef RDY_DEFINES__SV
`define RDY_DEFINES__SV

//--- if enable valid-rdy check   
// `define RDY_MON_CHECK
// `define VLD_RDY_DATA_WIDTH

`ifdef RDY_MON_CHECK
    `ifndef VLD_RDY_DATA_WIDTH
        `define VLD_RDY_DATA_WIDTH 1
    `endif
`endif

// assertion 
`define assert_handshake(clk, rst_n, name, vld, data, rdy)      \
    property p_``name``_vld;                                    \
        @(posedge clk) disable iff( !rst_n )                    \
        not $isunknown(vld);                                    \ 
    endproperty                                                 \
                                                                \
    property p_``name``_rdy;                                    \
        @(posedge clk) disable iff( !rst_n )                    \
        not $isunknown(rdy);                                    \
    endproperty                                                 \
                                                                \
    property p_``name``_data;                                   \
        @(posedge clk) disable iff( !rst_n )                    \
        vld |-> not $isunknown(data);                           \
    endproperty                                                 \
                                                                \
    property p_``name``_data_stable;                            \
        @(posedge clk) disable iff( !rst_n )                    \
        (vld & ~rdy) |=> $stable(data);                         \
    endproperty                                                 \
                                                                \
    a_``name``_vld         : assert property( p_``name``_vld        )    \
                             else `uvm_fatal(`"p_``name``_vld`",`"``vld`` have x/z state!`") \
    a_``name``_rdy         : assert property( p_``name``_rdy        )    \
                             else `uvm_fatal(`"p_``name``_rdy`",`"``rdy`` have x/z state!`") \
    a_``name``_data        : assert property( p_``name``_data       )    \
                             else `uvm_fatal(`"p_``name``_data`",`"when ``vld`` is valid, the ``data`` have x/z state!`") \
    a_``name``_data_stable : assert property( p_``name``_data_stable)    \
                             else `uvm_fatal(`"p_``name``_data_stable`",`"when handshake not finish, ``data`` changed!`") \
    c_``name``_data_stable : cover  property( p_``name``_data_stable); 

`endif

